function userLogin() {
    var email = $("#email").val().trim();
    var password = $("#password").val().trim();
    alert(email);
    alert(password);
    var ok = true;
    if (email == "") {
        alert("ok")
        $("#email_span").text("Email cannot be empty");
        ok = false;
    }
    if (password == "") {
        alert("ok")
        $("#password_span").text("Password cannot be empty");
        ok = false;
    }

    //获取当前网址，如： http://localhost:8083/uimcardprj/share/meun.jsp
    var curWwwPath = window.document.location.href;
    //获取主机地址之后的目录，如： uimcardprj/share/meun.jsp
    var pathName = window.document.location.pathname;
    var pos = curWwwPath.indexOf(pathName);
    //获取主机地址，如： http://localhost:8083
    var localhostPaht = curWwwPath.substring(0, pos);

    alert(curWwwPath + "_" + pathName + "_" + localhostPaht);
    if (ok) {
        $.ajax({
            url: curWwwPath + "/user/login.do",
            type: "post",
            data: {"email": email, "password": password},
            dataType: "json",
            success: function (data) {
                alert(data.msg);
                if (data.msg == "success") {
                    window.location = "index.html";
                }
            },
            error: function () {
                alert("error");
            }
        });
    }
    /*var xmlhttp;

    if (window.XMLHttpRequest)
    {
        // IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
        xmlhttp=new XMLHttpRequest();
    }
    else
    {
        // IE6, IE5 浏览器执行代码
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange=function()
    {
        if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
            window.location.href=curWwwPath+"index.html";
        }
    }
    xmlhttp.open("GET",curWwwPath+"user/login.do",true);
    xmlhttp.send();*/
}

function userSign() {
    $("#signup").hide();
    $("#login").hide();
    $("#warning").hide();
    $("#signdiv").show(100);
    $("#surepwd").show(100);

}

function cancel() {
    $("#signup").show(100);
    $("#login").show(100);
    $("#warning").show(100);
    $("#signdiv").hide();
    $("#surepwd").hide();
}

function confirm() {
    var password = $("#password").val();
    var finpwd = $("#finpwd").val();
    var email = $("#email").val();

    alert(email + "||" + finpwd + "||" + password);

    var curWwwPath = window.document.location.href;
    if (finpwd != null &&password != null && password==finpwd){
        $.ajax({
            url: curWwwPath + "/user/adduser.do",
            type: "post",
            data: {"email": email, "password": password},
            dataType: "json",
            success: function (data) {
                alert(data.msg);
                history.go(0)
                if (data.msg == "success") {
                    // window.location = "lgin.htmlo";
                    // location.reload();
                    history.go(0)
                }
            },
            error: function () {
                alert("error");
                history.go(0)
            }
        });
    }else{
        alert("Entered passwords differ");
        return
    }

    function checkId() {
        var email = $("#email").val();
        alert(email);

        if(email!=null){
            $.ajax({
                url: curWwwPath + "/user/adduser.do",
                type: "post",
                data: {"email": email, "password": password},
                dataType: "json",
                success: function (data) {
                    alert(data.msg);
                    if (data.msg == "success") {
                        window.location = "login.html";
                    }
                },
                error: function () {
                    alert("error");

                }
            });
        }
    }
}